import React from "react"
import { Toast, WhiteSpace, WingBlank, Button } from 'antd-mobile';
import qq from '../../imgs/QQ .png'
import email from "../../imgs/21 E-mail.png"
import wy from "../../imgs/网易云.png"
import weixin from "../../imgs/weixin.png"
import { withRouter } from "react-router-dom"
@withRouter
class Login extends React.Component {
    constructor(){
        super();
        this.state={
            checked:"false"
        }
    }
  componentDidMount() {
    Toast.loading('Loading...', 30, () => {
    });
    setTimeout(() => {
      Toast.hide();
    }, 3000);
  }
check(){
    this.setState({
        checked:this.state.checked=="false"?"true":"false"
    })
}
showToast() {
    if(this.state.checked=="false"){
  Toast.info('请勾选同意《用户协议》《隐私政策》《儿童隐私政策》', 1);
}else{
    let { history } = this.props;
    history.push("/login/phonelogin")
}
}
showToast1() {
    if(this.state.checked=="false"){
  Toast.info('请勾选同意《用户协议》《隐私政策》《儿童隐私政策》', 1);
}else{
    Toast.info('此功能待开发', 1);
}
}
tiyan(){
  let { history } = this.props;
    history.push("/my")
}
  render() {
    const p=JSON.parse(localStorage.getItem("login_info")).profile==undefined?JSON.parse(localStorage.getItem("login_info")).p:"";
    // console.log(p)
    return (
        <div className="sstlogin">
            <img src={wy} className="wy"/>
            <WingBlank>
        <WhiteSpace />
           </WingBlank>
           <button onClick={this.showToast.bind(this)} className="phone">手机号登陆</button>
           <p className="p" onClick={this.tiyan.bind(this)}>{p}</p>
           <div className="sstbottom">
           <img src={qq} onClick={this.showToast.bind(this)} className="qq"/>
           <img src={email} onClick={this.showToast.bind(this)} className="email"/>
           <img src={weixin} onClick={this.showToast1.bind(this)} className="qq"/>
           </div>
           <div className='sstcheck'>
           <input type='checkbox' onClick={this.check.bind(this)} />
           <span>同意《用户协议》《隐私政策》《儿童隐私政策》</span>
           </div>
        </div> 
    );
  }
}

 export default Login